/*
 * Copyright the original author or authors.
 * 
 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.mozilla.org/MPL/MPL-1.1.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
package com.bourre.view 
{
	import com.bourre.events.StringEvent;

	/**
	 * An event object which carry a <code>View</code> value.
	 * 
	 * @see View
	 * 
	 * @author Romain Ecarnot
	 */
	public class ViewEvent extends StringEvent 
	{
		//--------------------------------------------------------------------
		// Events
		//--------------------------------------------------------------------
				
		/**
		 * Defines the value of the <code>type</code> property of the event 
		 * object for a <code>onInitView</code> event.
		 * 
		 * <p>The properties of the event object have the following values:</p>
		 * <table class="innertable">
		 *     <tr><th>Property</th><th>Value</th></tr>
		 *     <tr>
		 *     	<td><code>type</code></td>
		 *     	<td>Dispatched event type</td>
		 *     </tr>
		 *     
		 *     <tr><th>Method</th><th>Value</th></tr>
		 *     <tr>
		 *     	<td><code>getView()</code>
		 *     	</td><td>The view object</td>
		 *     </tr>
		 *     <tr>
		 *     	<td><code>getViewID()</code>
		 *     	</td><td>The view identifier</td>
		 *     </tr>
		 * </table>
		 * 
		 * @eventType onInitView
		 */
		public static const onInitViewEVENT : String = "onInitView";

		/**
		 * Defines the value of the <code>type</code> property of the event 
		 * object for a <code>onReleaseView</code> event.
		 * 
		 * <p>The properties of the event object have the following values:</p>
		 * <table class="innertable">
		 *     <tr><th>Property</th><th>Value</th></tr>
		 *     <tr>
		 *     	<td><code>type</code></td>
		 *     	<td>Dispatched event type</td>
		 *     </tr>
		 *     
		 *     <tr><th>Method</th><th>Value</th></tr>
		 *     <tr>
		 *     	<td><code>getView()</code>
		 *     	</td><td>The view object</td>
		 *     </tr>
		 *      <tr>
		 *     	<td><code>getViewID()</code>
		 *     	</td><td>The view identifier</td>
		 *     </tr>
		 * </table>
		 * 
		 * @eventType onReleaseView
		 */	
		public static const onReleaseViewEVENT : String = "onReleaseView";

		
		//--------------------------------------------------------------------
		// Public API
		//--------------------------------------------------------------------
		
		/**
		 * Creates a new <code>ViewEvent</code> object.
		 * 
		 * @param	type			Name of the event type
		 * @param	view			View object carried by this event
		 */	
		public function ViewEvent(type : String, view : View = null, name : String = null )
		{
			super( type, view, name );
		}
		
		/**
		 * Returns the view object carried by this event.
		 * 
		 * @return	The view object carried by this event.
		 */
		public function getView() : View
		{
			return super.getTarget() as View;
		}
		
		/**
		 * Returns the view name carried by this event.
		 * 
		 * @return	The view name carried by this event.
		 */
		public function getViewID(  ) : String
		{
			return getString();
		}
	}
}
